//
//  HoroscopePayViewController.m
//  SubscribeBase
//
//  Created by qinjiandong on 2018/7/14.
//  Copyright © 2018年 changshuai. All rights reserved.
//

#import "HoroscopePayViewController.h"
#import "AppState.h"
#import "QCClauseVC.h"

@interface HoroscopePayViewController ()
@property (weak, nonatomic) IBOutlet UIButton *payBtn;

@end

@implementation HoroscopePayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addObserver];
    self.navigationItem.title = @"iHoroscope";
    [self.navigationItem.backBarButtonItem setTitle:@"back"];
    if (AppStateInstance.versionCode == CC_APP_STATE_R) {
        [self.payBtn setTitle:@"Continue" forState:UIControlStateNormal];
    }else{
        [self.payBtn setTitle:@"Continue" forState:UIControlStateNormal];
    }
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}


-(void)addObserver{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(purchasedDidFinished) name:kSRProductPurchasedNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(progressDismiss) name:kSRProductPurchasedFailNotification object:nil];
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(progressDismiss) name:kSRProductRestoredNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(progressDismiss) name:kSRProductRestoreDidSuccessNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(progressDismiss) name:kSRProductRestoreDidFailedNotification object:nil];
    
}
- (void)purchasedDidFinished{
    
    
}
- (void)progressDismiss{
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    

    
}
- (IBAction)payNowAction:(UIButton *)sender {
    if (AppStateInstance.versionCode == CC_APP_STATE_R || AppStateInstance.versionCode == CC_APP_STATE_INIT) {
        
        QCClauseVC* clauseVc = [[QCClauseVC alloc] init];
        UIBarButtonItem *backBtn = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
        self.navigationItem.backBarButtonItem = backBtn;
        [self.navigationController pushViewController:clauseVc animated:YES];
        
        
    }else{
        [[SRSubscriptionModel shareKit] makePurchase:SRSubscription];
    }
}
/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
